<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>
<body>
  <div id="app">
    <common-head></common-head>
    
  </div>
  <script src="./vue.js"></script>
  <script>
    // 子组件
    const Child = {
      inject: ['a','c'],
      template: `
        <div>
          <h3>这是子组件</h3>  
          {{ a }}
          <br/>
          {{ c }}
        </div>
      `,
      mounted(){
        console.log(this);
      }
    }
    const CommonHead = {
      provide: {
        // 向子组件提供的数据 起名字
        a: '字符串',
        b: 20,
        c: [1,2,3]
      },
      template: `
        <div>
          <h2>这是一个公共的 头部组件</h2>  
          <child></child>
        </div>
      `,
      components: {
        Child
      }
    };
    Vue.component('CommonHead', CommonHead)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>